<?php
/*
 * mk script file created on 10-mag-2005
 * jaco_at_pixeldump_dot_org
 * image to swf
 */

include("sample_utils.php");                             // provides some utils and using mk

$imageFN = "85569310_beac638d2f.jpg";                    // source image file name

$bm = new BitmapItem();                                 // mk bitmap item class
$bmTag = $bm->create_from_file($imageFN);                // create swf tag from file
$bitmapWidth = $bm->get_bitmapWidth();                   //
$bitmapHeight = $bm->get_bitmapHeight();                 // width, height of image

$mad = array();                                          // this ...
$mad["x"] = 150;                                         // ... array is used ...
$mad["y"] = 20;                                          // ... to place bitmap
$mad["width"] = $bitmapWidth;                            // ... properly
$mad["height"] = $bitmapHeight;                          //

$shape1 = new MKShapeContainer("", 2);                 // the shape that will wrap bitmap

// add a bitmap fill, there are some kind
// for a single bounded image use CLIPPED_BITMAP_FILL
// the last parameter will place the bitmap in the desired position
// note that in this case we set position for bitmap, not for shape itself
$shape1->add_bitmap_fill(1, CLIPPED_BITMAP_FILL, $mad);
$shape1->add_rect($mad["x"], $mad["y"], $mad["width"], $mad["height"]); // image bounding box

$shapeTD1 = $shape1->update_tagData();				     // get shape tag
$shapePB1 = $shape1->update_place_tagData();

$swf = new MKSwf("bitmap.swf");                          // start a fresh swf
$swf->set_swfDir(SERVER_MKTMP);                          // change default working dir
$swf->set_backgroundColor("#FF9933");                    // change background color
$swf->add_tagData($bmTag);                               // populate with image
$swf->add_tagData($shapeTD1);                            // populate with shape wrapper
$swf->add_tagData($shapePB1);                            // place on stage
$swf->swf_output();                                      // save to disk

$swfHeader = $swf->fetch_assoc();

$str = "<br />" .render_swf_box($swfHeader, $imgDir, false, false, true);
$str .= "<br/><br/><strong>bitmap.swf created in " .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
